import { adminRouter, commonRouter } from '../testrouter'
import { userInfo } from '../../stores/userInfo'
import request from '../../utils/request'

/**
 * 模拟获取后端返回的路由集合
 * @returns {Promise<unknown>}
 */
export const getRouterListFun = () => {
  const username = userInfo().getUserInfo().userName
  return new Promise((resolve, reject) => {
    resolve(adminRouter())
  })
}

// 获取当前人员的路由信息
export const getRoutersFun = () => {
  return request({
    url: '/getRouters',
    method: 'get',
  })
}

// 获取所有菜单列表
export function menuListFun(menuName?: any) {
  return request({
    url: '/system/menu/list',
    method: 'get',
    params: {
      menuName,
    },
  })
}

// 新增菜单
export function addMenuFun(data: any) {
  return request({
    url: '/system/menu',
    method: 'post',
    data: data,
  })
}

// 修改菜单
export function updateMenuFun(data: any) {
  return request({
    url: '/system/menu',
    method: 'put',
    data: data,
  })
}

// 删除菜单
export function delMenuFun(menuId: any) {
  return request({
    url: '/system/menu/' + menuId,
    method: 'delete',
  })
}
